package com.celesea.configuration.redis;

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import redis.clients.jedis.JedisPoolConfig;

/**
 * @author Jack
 */
public abstract class AbstractRedisProperties {

    public JedisConnectionFactory connectionFactory(){
        JedisConnectionFactory connection = new JedisConnectionFactory();
        connection.setPort(this.getPort());
        connection.setHostName(this.getHost());
        connection.setPassword(this.getPassword());
        connection.setDatabase(this.getDatabase());
        connection.setTimeout(this.getTimeout());
        JedisPoolConfig config = new JedisPoolConfig();
        config.setMaxIdle(this.getJedisPoolMaxIdle());
        config.setMaxTotal(this.getJedisPoolMaxTotal());
        config.setMaxWaitMillis(this.getJedisPoolMaxWait());
        connection.setPoolConfig(config);
        return connection;
    }
    
    public abstract String getHost();

    public abstract Integer getPort();

    public abstract Integer getDatabase();

    public abstract String getPassword();

    public abstract Integer getTimeout();

    public abstract Integer getJedisPoolMaxIdle();

    public abstract Integer getJedisPoolMaxTotal();

    public abstract Integer getJedisPoolMaxWait();
}
